package main.od;

import java.util.Arrays;
import java.util.Scanner;

public class AbrTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] aArr =Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] bArr =Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int r = Integer.parseInt(sc.nextLine());
        boolean flag = false;
        int near = -1;
        for (int a : aArr){
            for (int b : bArr){
                if (b - a <= r && a <= b){
                    System.out.println("(" + a + "," + b + ")");
                    flag = true;
                }
                if (b - a > r){
                    near = b;
                    break;
                }
            }
            if (!flag && near != -1){
                System.out.println("(" + a + "," + near + ")");
            }
        }
    }
}
